package com.hlk.utils;

import com.github.pagehelper.PageInfo;

import java.util.List;

/**
 * @author hlk
 * @version 1.0
 * @date 2020-12-29 14:32
 */
public class PageUtils {

    /**
     * 获取分页结果
     *
     * @param page
     * @param list
     * @return
     */
    public static PageResult getResult(Integer page, List<?> list) {
        PageInfo<?> pageList = new PageInfo<>(list);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setPage(page);
        pageResult.setRecords(pageList.getTotal());
        pageResult.setTotal(pageList.getPages());
        return pageResult;
    }
}
